#ifndef _PRODUCERIMPL_H_
#define _PRODUCERIMPL_H_

#include "stdafx.h"
#include "auth.hpp"
#include "msgbuschannel.hpp"

#define TCP_CONSUMER_CONNECT 100

class CProducerImpl : public IProducer, public IOperationProc, public CMsgbusChannel, public CUnknownImp

{
public:
    CProducerImpl(void);
    virtual ~CProducerImpl(void);

    BEGIN_STDCOM_MAP
    STDCOM_INTERFACE_ENTRY_UNKNOWN_(IProducer)
    STDCOM_INTERFACE_ENTRY(IOperationProc)
    STDCOM_INTERFACE_ENTRY(IProducer)
    END_STDCOM_MAP

public:
    // IProducer
    std_method(SetId)(unsigned int id);
    std_method(Bind)(LPCSTR addr, int len);
    std_method(Close)();
    std_method(Send)(IBase* pBase);

    // IOperationProc
    std_method(OnComplete)(IBase* pOperation, crtid cid, crterr err);

private:
    std_method(OnConnected)(IBase* pIBase);
    std_method(OnSendSeqed)(IBase* pIBase);
    std_method(OnRecvSeqAcked)(IBase* pIBase);
    std_method(OnSendAcked)(IBase* pIBase);
    std_method(OnSendHeaded)(IBase* pIBase);
    std_method(OnSended)(IBase* pIBase);

private:
    CSemHandle m_sem;
    unsigned int m_id;
};

#endif
